const cozeWebSDK = new CozeWebSDK.WebChatClient({
  config: {
    // 智能体 ID
    botId: '7533972308495630372',
    isIframe: false,
    // 给自定义参数赋值并传给对话流
    botInfo: {
      parameters: {
        user_name: 'John'
      }
    }
  },
  auth: {
    // Authentication methods, the default type is 'unauth', which means no authentication is required; it is recommended to set it to 'token', indicating authentication through PAT (Personal Access Token) or OAuth
    type: 'token',
    // When the type is set to 'token', it is necessary to configure a PAT (Personal Access Token) or OAuth access token for authentication.
    token: 'pat_VGZWE08nbw4wLlBg7Phyyot77BHL5kX6RDeq9ekv4SQW4hZOxmAedgaU8DHZMv23',
    // When the access token expires, use a new token and set it as needed.
    onRefreshToken: async () => 'pat_VGZWE08nbw4wLlBg7Phyyot77BHL5kX6RDeq9ekv4SQW4hZOxmAedgaU8DHZMv23',
  },
  userInfo: {
    id: '123',
    url: 'https://lf-coze-web-cdn.coze.cn/obj/coze-web-cn/obric/coze/favicon.1970.png',
    nickname: '3qweqweqwe',
  },
  ui: {
    base: {
      icon: 'https://lf-coze-web-cdn.coze.cn/obj/coze-web-cn/obric/coze/favicon.1970.png',
      layout: 'pc',
      zIndex: 1000,
    },
    asstBtn: {
      isNeed: false,
    },
    //聊天框顶部默认展示智能体名称、icon、及关闭按钮。默认都展示
    header: {
      isShow: true,
      isNeedClose: true,
    },
    footer: {
      isShow: true,
      expressionText: 'Powered by {{name}}-generated content for reference only.',
      linkvars: {
        name: {
          text: 'liyp',
          link: 'https://gitee.com/yami0109/coze-project'
        }
      }
    },
    chatBot: {
      title: "市场舆情监测助手",
      uploadable: true,
      width: 800,
      el: document.getElementById('id1'),
      isNeedFunctionCallMessage: true,
      isNeedAddNewConversation: true,
      isNeedQuote: true,
      onHide: () => {
        // todo...
      },
      onShow: () => {
        // todo...
      },
      //消息评价
      feedback: {
        isNeedFeedback: true,
        feedbackPanel: {
          title: '您对这个回答有什么看法？请告诉我们',
          placeholder: '请详细描述您的问题...',
          tags: [
            {
              label: '信息不正确',
              isNeedDetail: false
            },
            {
              label: '涉及敏感信息',
              isNeedDetail: true
            },
            {
              label: '回答不够详细',
              isNeedDetail: true
            },
            {
              label: '其他问题',
              isNeedDetail: true
            }
          ],
          onSubmit: (feedback) => {
            console.log('用户反馈:', feedback);
            // 这里可以处理反馈数据
          }
        }
      }

    },
    // chatBot: {
    //   el: document.getElementById('id1')
    // }
  },
});

// 页面加载完成后自动显示聊天机器人
window.addEventListener('DOMContentLoaded', () => {
  cozeWebSDK.showChatBot();
});